import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:freedom/widget/common_alter_dialog.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class UserAgreement extends StatefulWidget {
    final CancelFunc cancelFunc;
  const UserAgreement(this.cancelFunc, {super.key});
  @override
  _UserAgreementState createState() => _UserAgreementState();
}

class _UserAgreementState extends State<UserAgreement> {
  var _userAgreement = "";

  Future<String> loadAsset() async {
    var a = await rootBundle.loadString('assets/data/useragreement.txt');
    return a;
  }

  dynamic result;
  void loadAssests() async {
    result = await loadAsset();
    _userAgreement = result.toString();
    setState(() {});
  }

  @override
  void initState() {
    loadAssests();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return CommonAlterDialog(
      backgroundColor: Colors.white,
      closeWindow: widget.cancelFunc,
      child: Column(
        children: [
          Container(
              height: 40.h,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text(
                    "逍遥棋牌",
                    style: TextStyle(fontSize: 20.sp),
                  ),
                  Container(
                    margin:
                        EdgeInsets.symmetric(horizontal: 10.w, vertical: 10.h),
                    child: DecoratedBox(
                      decoration: BoxDecoration(color: Colors.grey),
                    ),
                    height: 40.h,
                    width: 1,
                  ),
                  Text(
                    "用户协议",
                    style: TextStyle(fontSize: 20.sp),
                  )
                ],
              )),
          Expanded(
              child: Scrollbar(
            child: SingleChildScrollView(
                child: Container(
              padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 10.h),
              child: Text(
                _userAgreement,
                style: TextStyle(fontSize: 18.sp, color: Colors.black),
              ),
            )),
          ))
        ],
      ),
    );
  }
}
